package com.syh.jn.scm.infrastructure.repository.impl.supplier.system;

import cn.redscarf.commons.wrapper.Wrapper;
import com.syh.core.ddd.infrastructure.repository.AggregateRepoHibernateImplTmpl;
import com.syh.jn.scm.domain.supplier.entity.system.SupplierAccountOfPhone;
import com.syh.jn.scm.domain.supplier.repository.system.SupplierAccountOfPhoneRepository;
import com.syh.jn.scm.infrastructure.repository.model.system.AccountOfPhoneModel;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by soci.song on 2018/12/13.
 */
@Log
@Repository
public class SupplierAccountOfPhoneRepositoryImpl implements SupplierAccountOfPhoneRepository {

  private AggregateRepoHibernateImplTmpl<SupplierAccountOfPhone, AccountOfPhoneModel, Long> hibernateImplTmpl;

  @Autowired
  public SupplierAccountOfPhoneRepositoryImpl(HibernateTemplate hibernateTemplate) {
    this.hibernateImplTmpl = new AggregateRepoHibernateImplTmpl.Builder().hibernateTemplate(hibernateTemplate)
            .entityClass(SupplierAccountOfPhone.class).modelClass(AccountOfPhoneModel.class).idClass(Long.class).build();
  }


  @Override
  public Long add(SupplierAccountOfPhone entity) {
    AccountOfPhoneModel model = hibernateImplTmpl.add(entity);
    return model.getId();
  }

  @Override
  public void update(SupplierAccountOfPhone entity) {
    hibernateImplTmpl.update(entity);
  }

  @Override
  public void removeById(Long id) {
    hibernateImplTmpl.removeById(id);
  }

  @Override
  public void remove(SupplierAccountOfPhone entity) {
    hibernateImplTmpl.remove(entity);
  }

  @Override
  public SupplierAccountOfPhone getById(Long id) {
    return hibernateImplTmpl.getById(id);
  }

  @Override
  public SupplierAccountOfPhone getOne(Wrapper wrapper) {
    return hibernateImplTmpl.getOne(wrapper);
  }

  @Override
  public List<SupplierAccountOfPhone> getList(Wrapper wrapper) {
    return hibernateImplTmpl.getList(wrapper);
  }

  @Override
  public List<SupplierAccountOfPhone> findListPage(Wrapper wrapper, Integer startRow, Integer count) {
    return hibernateImplTmpl.findListPage(wrapper, startRow, count);
  }

  @Override
  public int getCount(Wrapper wrapper) {
    return hibernateImplTmpl.getCount(wrapper);
  }

  @Override
  public boolean contains(Long aLong) {
    return hibernateImplTmpl.contains(aLong);
  }

}
